{% extends 'app01/article_cellation.html' %}

{% block person_manage %}
    <a class="navbar-brand" href="#">我的班级{{ request.user.stu_class }}</a>
{% endblock %}

{% block all_li %}
    <li role="presentation" class="active">
        <a href="#home" aria-controls="home" role="tab" data-toggle="tab">班级:{{ request.user.stu_class }}</a></li>
    <li role="presentation" class="active">
        <a href="{% url 'app01_backend' %}" style="color: #337ab7">返回个人管理</a></li>

{% endblock %}

{% block all_content %}
    {% block suibi %}
        {% for person in c_page %}
            <div class="media">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object" src="/media/{{ person.avatar }}" height="64" alt="...">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading"><a href="/app01/site/{{ person.username }}?url={{ request.get_full_path_info }}">{{ person.username }}</a></h4>
                    <p><span
                            class="glyphicon glyphicon-bullhorn">个人签名&nbsp;{{ person.blog.site_title }} </span></p>
                    <p><a href="/app01/userwechat?pk={{ person.id }}">发起私信 <span
                            class="glyphicon glyphicon-comment"></span> </a></p>
                </div>
            </div>
            <hr>
        {% empty %}
            <h2>您还没有加入班级。</h2>
        {% endfor %}

        {# 分页显示 #}
        <div class="pager">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    {{ page_html }}
                </ul>
            </nav>
        </div>

    {% endblock %}

{% endblock %}

{% block js %}
    <script>
    //我的班级的超链接
    if('{{ request.user.username }}'.slice(0,3)==='312'){
        $('#MyClass').html("<a href='/app01/myclass/'> 我的班级 </a>")
    }

        //文件上传的ajax请求
        $("#up_btn_id").click(function () {
            let formObj = new FormData()
            formObj.append('file', $('#up_file_id')[0].files[0])
            formObj.append('filename', $('#file_name_id').val())
            formObj.append('desc', $('#file_desc_id').val())
            let radio_chioce = $('input[name="share"]:checked').val();
            formObj.append('share', radio_chioce)

            $.ajax({
                url: "/app01/upload_file/",
                type: 'post',
                data: formObj,
                contentType: false,
                processData: false,
                success: function (array) {
                    if (array.code === 1000) {
                        alert(array.msg0)
                        parent.location.href = array.url
                    } else if (array.code === 2000) {
                        //用户输入不正确的提示
                        $('#p1').next().text(array.msg1)
                        $('#p2').next().text(array.msg2)
                        $('#p3').next().text(array.msg3)
                    } else {
                        alert(array.msg0)
                    }

                }
            })


        });
    </script>
{% endblock %}